package cc.prayol.permission.mapper.auth;

import static cc.prayol.permission.mapper.auth.JobDynamicSqlSupport.*;
import static org.mybatis.dynamic.sql.SqlBuilder.*;

import cc.prayol.permission.entity.auth.Job;
import java.util.List;
import java.util.Optional;
import javax.annotation.Generated;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;
import org.mybatis.dynamic.sql.BasicColumn;
import org.mybatis.dynamic.sql.delete.DeleteDSLCompleter;
import org.mybatis.dynamic.sql.delete.render.DeleteStatementProvider;
import org.mybatis.dynamic.sql.insert.render.InsertStatementProvider;
import org.mybatis.dynamic.sql.select.CountDSLCompleter;
import org.mybatis.dynamic.sql.select.SelectDSLCompleter;
import org.mybatis.dynamic.sql.select.render.SelectStatementProvider;
import org.mybatis.dynamic.sql.update.UpdateDSL;
import org.mybatis.dynamic.sql.update.UpdateDSLCompleter;
import org.mybatis.dynamic.sql.update.UpdateModel;
import org.mybatis.dynamic.sql.update.render.UpdateStatementProvider;
import org.mybatis.dynamic.sql.util.SqlProviderAdapter;
import org.mybatis.dynamic.sql.util.mybatis3.MyBatis3Utils;

@Mapper
public interface JobMapper {
    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.596+08:00", comments="Source Table: sys_job")
    BasicColumn[] selectList = BasicColumn.columnList(jobId, jobName, className, jobParams, cron, paused, remark, updateTime, createTime, deleted, createBy, updateBy);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.595+08:00", comments="Source Table: sys_job")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    long count(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.595+08:00", comments="Source Table: sys_job")
    @DeleteProvider(type=SqlProviderAdapter.class, method="delete")
    int delete(DeleteStatementProvider deleteStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.595+08:00", comments="Source Table: sys_job")
    @InsertProvider(type=SqlProviderAdapter.class, method="insert")
    int insert(InsertStatementProvider<Job> insertStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.595+08:00", comments="Source Table: sys_job")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @ResultMap("JobResult")
    Optional<Job> selectOne(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.595+08:00", comments="Source Table: sys_job")
    @SelectProvider(type=SqlProviderAdapter.class, method="select")
    @Results(id="JobResult", value = {
        @Result(column="job_id", property="jobId", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="job_name", property="jobName", jdbcType=JdbcType.VARCHAR, id=true),
        @Result(column="class_name", property="className", jdbcType=JdbcType.VARCHAR),
        @Result(column="job_params", property="jobParams", jdbcType=JdbcType.VARCHAR),
        @Result(column="cron", property="cron", jdbcType=JdbcType.VARCHAR),
        @Result(column="paused", property="paused", jdbcType=JdbcType.BIT),
        @Result(column="remark", property="remark", jdbcType=JdbcType.VARCHAR),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="deleted", property="deleted", jdbcType=JdbcType.BIT),
        @Result(column="create_by", property="createBy", jdbcType=JdbcType.VARCHAR),
        @Result(column="update_by", property="updateBy", jdbcType=JdbcType.VARCHAR)
    })
    List<Job> selectMany(SelectStatementProvider selectStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.595+08:00", comments="Source Table: sys_job")
    @UpdateProvider(type=SqlProviderAdapter.class, method="update")
    int update(UpdateStatementProvider updateStatement);

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.595+08:00", comments="Source Table: sys_job")
    default long count(CountDSLCompleter completer) {
        return MyBatis3Utils.countFrom(this::count, job, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.596+08:00", comments="Source Table: sys_job")
    default int delete(DeleteDSLCompleter completer) {
        return MyBatis3Utils.deleteFrom(this::delete, job, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.596+08:00", comments="Source Table: sys_job")
    default int deleteByPrimaryKey(Long jobId_, String jobName_) {
        return delete(c -> 
            c.where(jobId, isEqualTo(jobId_))
            .and(jobName, isEqualTo(jobName_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.596+08:00", comments="Source Table: sys_job")
    default int insert(Job record) {
        return MyBatis3Utils.insert(this::insert, record, job, c ->
            c.map(jobId).toProperty("jobId")
            .map(jobName).toProperty("jobName")
            .map(className).toProperty("className")
            .map(jobParams).toProperty("jobParams")
            .map(cron).toProperty("cron")
            .map(paused).toProperty("paused")
            .map(remark).toProperty("remark")
            .map(updateTime).toProperty("updateTime")
            .map(createTime).toProperty("createTime")
            .map(deleted).toProperty("deleted")
            .map(createBy).toProperty("createBy")
            .map(updateBy).toProperty("updateBy")
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.596+08:00", comments="Source Table: sys_job")
    default int insertSelective(Job record) {
        return MyBatis3Utils.insert(this::insert, record, job, c ->
            c.map(jobId).toPropertyWhenPresent("jobId", record::getJobId)
            .map(jobName).toPropertyWhenPresent("jobName", record::getJobName)
            .map(className).toPropertyWhenPresent("className", record::getClassName)
            .map(jobParams).toPropertyWhenPresent("jobParams", record::getJobParams)
            .map(cron).toPropertyWhenPresent("cron", record::getCron)
            .map(paused).toPropertyWhenPresent("paused", record::getPaused)
            .map(remark).toPropertyWhenPresent("remark", record::getRemark)
            .map(updateTime).toPropertyWhenPresent("updateTime", record::getUpdateTime)
            .map(createTime).toPropertyWhenPresent("createTime", record::getCreateTime)
            .map(deleted).toPropertyWhenPresent("deleted", record::getDeleted)
            .map(createBy).toPropertyWhenPresent("createBy", record::getCreateBy)
            .map(updateBy).toPropertyWhenPresent("updateBy", record::getUpdateBy)
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.596+08:00", comments="Source Table: sys_job")
    default Optional<Job> selectOne(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectOne(this::selectOne, selectList, job, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.596+08:00", comments="Source Table: sys_job")
    default List<Job> select(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectList(this::selectMany, selectList, job, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.596+08:00", comments="Source Table: sys_job")
    default List<Job> selectDistinct(SelectDSLCompleter completer) {
        return MyBatis3Utils.selectDistinct(this::selectMany, selectList, job, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.596+08:00", comments="Source Table: sys_job")
    default Optional<Job> selectByPrimaryKey(Long jobId_, String jobName_) {
        return selectOne(c ->
            c.where(jobId, isEqualTo(jobId_))
            .and(jobName, isEqualTo(jobName_))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.596+08:00", comments="Source Table: sys_job")
    default int update(UpdateDSLCompleter completer) {
        return MyBatis3Utils.update(this::update, job, completer);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.596+08:00", comments="Source Table: sys_job")
    static UpdateDSL<UpdateModel> updateAllColumns(Job record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(jobId).equalTo(record::getJobId)
                .set(jobName).equalTo(record::getJobName)
                .set(className).equalTo(record::getClassName)
                .set(jobParams).equalTo(record::getJobParams)
                .set(cron).equalTo(record::getCron)
                .set(paused).equalTo(record::getPaused)
                .set(remark).equalTo(record::getRemark)
                .set(updateTime).equalTo(record::getUpdateTime)
                .set(createTime).equalTo(record::getCreateTime)
                .set(deleted).equalTo(record::getDeleted)
                .set(createBy).equalTo(record::getCreateBy)
                .set(updateBy).equalTo(record::getUpdateBy);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.596+08:00", comments="Source Table: sys_job")
    static UpdateDSL<UpdateModel> updateSelectiveColumns(Job record, UpdateDSL<UpdateModel> dsl) {
        return dsl.set(jobId).equalToWhenPresent(record::getJobId)
                .set(jobName).equalToWhenPresent(record::getJobName)
                .set(className).equalToWhenPresent(record::getClassName)
                .set(jobParams).equalToWhenPresent(record::getJobParams)
                .set(cron).equalToWhenPresent(record::getCron)
                .set(paused).equalToWhenPresent(record::getPaused)
                .set(remark).equalToWhenPresent(record::getRemark)
                .set(updateTime).equalToWhenPresent(record::getUpdateTime)
                .set(createTime).equalToWhenPresent(record::getCreateTime)
                .set(deleted).equalToWhenPresent(record::getDeleted)
                .set(createBy).equalToWhenPresent(record::getCreateBy)
                .set(updateBy).equalToWhenPresent(record::getUpdateBy);
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.596+08:00", comments="Source Table: sys_job")
    default int updateByPrimaryKey(Job record) {
        return update(c ->
            c.set(className).equalTo(record::getClassName)
            .set(jobParams).equalTo(record::getJobParams)
            .set(cron).equalTo(record::getCron)
            .set(paused).equalTo(record::getPaused)
            .set(remark).equalTo(record::getRemark)
            .set(updateTime).equalTo(record::getUpdateTime)
            .set(createTime).equalTo(record::getCreateTime)
            .set(deleted).equalTo(record::getDeleted)
            .set(createBy).equalTo(record::getCreateBy)
            .set(updateBy).equalTo(record::getUpdateBy)
            .where(jobId, isEqualTo(record::getJobId))
            .and(jobName, isEqualTo(record::getJobName))
        );
    }

    @Generated(value="org.mybatis.generator.api.MyBatisGenerator", date="2020-09-07T20:11:24.596+08:00", comments="Source Table: sys_job")
    default int updateByPrimaryKeySelective(Job record) {
        return update(c ->
            c.set(className).equalToWhenPresent(record::getClassName)
            .set(jobParams).equalToWhenPresent(record::getJobParams)
            .set(cron).equalToWhenPresent(record::getCron)
            .set(paused).equalToWhenPresent(record::getPaused)
            .set(remark).equalToWhenPresent(record::getRemark)
            .set(updateTime).equalToWhenPresent(record::getUpdateTime)
            .set(createTime).equalToWhenPresent(record::getCreateTime)
            .set(deleted).equalToWhenPresent(record::getDeleted)
            .set(createBy).equalToWhenPresent(record::getCreateBy)
            .set(updateBy).equalToWhenPresent(record::getUpdateBy)
            .where(jobId, isEqualTo(record::getJobId))
            .and(jobName, isEqualTo(record::getJobName))
        );
    }
}